#ifndef FIFO_H
#define FIFO_H

#ifdef __cplusplus
extern "C" {
#endif

#include <stdint.h>

#define FIFO_SIZE    10

typedef enum {
    SENSOR_ACCEL = 0,
    SENSOR_TEMP,
    SENSOR_HUMID,
    SENSOR_MAGNETO,
    SENSOR_PRESSURE,
    SENSOR_GYRO
} SensorType_t;

typedef struct {
    SensorType_t type;
    uint32_t     msgIdx;
    union {
        struct { float x, y, z; } accel;
        float temp;
        float humidity;
        struct { int16_t x, y, z; } magneto;
        float pressure;
        struct { float x, y, z; } gyro;
    } data;
} SensorMsg_t;


typedef struct {
    SensorMsg_t buffer[FIFO_SIZE];
    int head;
    int tail;
    int count;
} FIFO_t;




void FIFO_Init(FIFO_t *fifo);

int FIFO_Push(FIFO_t *fifo, const SensorMsg_t *msg);

int FIFO_Pop(FIFO_t *fifo, SensorMsg_t *msg);
int FIFO_GetSize(FIFO_t *fifo);
#ifdef __cplusplus
}
#endif

#endif /* FIFO_H */
